package com.ec.fb.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.ec.common.exception.BadRequestException;
import lombok.Getter;

@Getter
public enum FeedbackRating {
    ONE(1, "一星"),
    TWO(2, "二星"),
    THREE(3, "三星"),
    FOUR(4, "四星"),
    FIVE(5, "五星");

    @EnumValue
    private final Integer value;
    private final String desc;

    FeedbackRating(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static FeedbackRating of(Integer value) {
        for (FeedbackRating rating : values()) {
            if (rating.value.equals(value)) {
                return rating;
            }
        }
        throw new BadRequestException("评分值错误");
    }
}